home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / wb-tools / toolmanager / source / library / config.c < prev    next >
C/C++ Source or Header  |  1994-06-06  |  18KB  |  556 lines

  1. /*
  2.  * config.c  V2.1
  3.  *
  4.  * config file handling
  5.  *
  6.  * (c) 1990-1993 Stefan Becker
  7.  */
  8.  
  9. #include "ToolManagerLib.h"
  10.  
  11. /* Config data structure */
  12. struct ConfigBufNode {
  13.                       struct MinNode cbn_Node;
  14.                       ULONG          cbn_Size;
  15.                      };
  16.  
  17. typedef BOOL (*ReadConfigFuncPtr)(struct ConfigBufNode *);
  18.  
  19. /* Private data */
  20. static struct List ConfigBufList;
  21. static BOOL clistinit=FALSE;
  22. static ULONG stopchunks[]={ID_PREF,ID_TMEX,
  23.                            ID_PREF,ID_TMIM,
  24.                            ID_PREF,ID_TMSO,
  25.                            ID_PREF,ID_TMMO,
  26.                            ID_PREF,ID_TMIC,
  27.                            ID_PREF,ID_TMDO,
  28.                            ID_PREF,ID_TMAC};
  29.  
  30. /* Get one config string and correct pointer */
  31. static char *GetConfigStr(UBYTE **buf)
  32. {
  33.  char *s=*buf;
  34.  ULONG len=strlen(s)+1;
  35.  
  36.  /* Correct pointer */
  37.  *buf+=len;
  38.  
  39.  /* Return pointer to config string */
  40.  return(s);
  41. }
  42.  
  43. static struct TagItem ExecPrefsTags[]={
  44.                                        TMOP_Command,    NULL,
  45.                                        TMOP_CurrentDir, NULL,
  46.                                        TMOP_HotKey,     NULL,
  47.                                        TMOP_Output,     NULL,
  48.                                        TMOP_Path,       NULL,
  49.                                        TMOP_PubScreen,  NULL,
  50.  
  51.                                        TMOP_Arguments,  FALSE,
  52.                                        TMOP_ToFront,    FALSE,
  53.  
  54.                                        TMOP_Delay,      0,
  55.                                        TMOP_ExecType,   0,
  56.                                        TMOP_Priority,   0,
  57.                                        TMOP_Stack,      0,
  58.  
  59.                                        TAG_DONE
  60.                                       };
  61.  
  62. /* Interpret TMEX chunk */
  63. static BOOL ReadExecConfig(struct ConfigBufNode *cbn)
  64. {
  65.  struct ExecPrefsObject *epo=(struct ExecPrefsObject *) &cbn[1];
  66.  ULONG sbits=epo->epo_StringBits;
  67.  UBYTE *ptr=(UBYTE *) &epo[1];
  68.  char *name;
  69.  
  70.  /* Get name string */
  71.  name=(sbits & EXPO_NAME) ? GetConfigStr(&ptr) : DefaultNoName;
  72.  
  73.  /* Set string tags */
  74.  ExecPrefsTags[ 0].ti_Data=(ULONG) ((sbits & EXPO_COMMAND) ?
  75.                                      GetConfigStr(&ptr) : NULL);
  76.  ExecPrefsTags[ 1].ti_Data=(ULONG) ((sbits & EXPO_CURDIR) ?
  77.                                      GetConfigStr(&ptr) : NULL);
  78.  ExecPrefsTags[ 2].ti_Data=(ULONG) ((sbits & EXPO_HOTKEY) ?
  79.                                      GetConfigStr(&ptr) : NULL);
  80.  ExecPrefsTags[ 3].ti_Data=(ULONG) ((sbits & EXPO_OUTPUT) ?
  81.                                      GetConfigStr(&ptr) : NULL);
  82.  ExecPrefsTags[ 4].ti_Data=(ULONG) ((sbits & EXPO_PATH) ?
  83.                                      GetConfigStr(&ptr) : NULL);
  84.  ExecPrefsTags[ 5].ti_Data=(ULONG) ((sbits & EXPO_PSCREEN) ?
  85.                                      GetConfigStr(&ptr) : NULL);
  86.  
  87.  /* Set boolean tags */
  88.  ExecPrefsTags[ 6].ti_Data=(epo->epo_Flags & EXPOF_ARGS)    != 0;
  89.  ExecPrefsTags[ 7].ti_Data=(epo->epo_Flags & EXPOF_TOFRONT) != 0;
  90.  
  91.  /* Set integer tags */
  92.  ExecPrefsTags[ 8].ti_Data=epo->epo_Delay;
  93.  ExecPrefsTags[ 9].ti_Data=epo->epo_ExecType;
  94.  ExecPrefsTags[10].ti_Data=epo->epo_Priority;
  95.  ExecPrefsTags[11].ti_Data=epo->epo_Stack;
  96.  
  97.  /* Create object */
  98.  return(InternalCreateTMObject(PrivateTMHandle,name,TMOBJTYPE_EXEC,
  99.                                ExecPrefsTags));
  100. }
  101.  
  102. static struct TagItem ImagePrefsTags[]={
  103.                                         TMOP_File, NULL,
  104.  
  105.                                         TAG_DONE
  106.                                        };
  107.  
  108. /* Interpret TMIM chunk */
  109. static BOOL ReadImageConfig(struct ConfigBufNode *cbn)
  110. {
  111.  struct ImagePrefsObject *ipo=(struct ImagePrefsObject *) &cbn[1];
  112.  ULONG sbits=ipo->ipo_StringBits;
  113.  UBYTE *ptr=(UBYTE *) &ipo[1];
  114.  char *name;
  115.  
  116.  /* Get name string */
  117.  name=(sbits & IMPO_NAME) ? GetConfigStr(&ptr) : DefaultNoName;
  118.  
  119.  /* Set string tags */
  120.  ImagePrefsTags[ 0].ti_Data=(ULONG) ((sbits & IMPO_FILE) ?
  121.                                       GetConfigStr(&ptr) : NULL);
  122.  
  123.  /* Create object */
  124.  return(InternalCreateTMObject(PrivateTMHandle,name,TMOBJTYPE_IMAGE,
  125.                                ImagePrefsTags));
  126. }
  127.  
  128. static struct TagItem SoundPrefsTags[]={
  129.                                         TMOP_Command, NULL,
  130.                                         TMOP_Port,    NULL,
  131.  
  132.                                         TAG_DONE
  133.                                        };
  134.  
  135. /* Interpret TMSO chunk */
  136. static BOOL ReadSoundConfig(struct ConfigBufNode *cbn)
  137. {
  138.  struct SoundPrefsObject *spo=(struct SoundPrefsObject *) &cbn[1];
  139.  ULONG sbits=spo->spo_StringBits;
  140.  UBYTE *ptr=(UBYTE *) &spo[1];
  141.  char *name;
  142.  
  143.  /* Get name string */
  144.  name=(sbits & SOPO_NAME) ? GetConfigStr(&ptr) : DefaultNoName;
  145.  
  146.  /* Set string tags */
  147.  SoundPrefsTags[ 0].ti_Data=(ULONG) ((sbits & SOPO_COMMAND) ?
  148.                                       GetConfigStr(&ptr) : NULL);
  149.  SoundPrefsTags[ 1].ti_Data=(ULONG) ((sbits & SOPO_PORT) ?
  150.                                       GetConfigStr(&ptr) : NULL);
  151.  
  152.  /* Create object */
  153.  return(InternalCreateTMObject(PrivateTMHandle,name,TMOBJTYPE_SOUND,
  154.                                SoundPrefsTags));
  155. }
  156.  
  157. static struct TagItem MenuPrefsTags[]={
  158.                                        TMOP_Exec,  NULL,
  159.                                        TMOP_Sound, NULL,
  160.  
  161.                                        TAG_DONE
  162.                                       };
  163.  
  164. /* Interpret TMMO chunk */
  165. static BOOL ReadMenuConfig(struct ConfigBufNode *cbn)
  166. {
  167.  struct MenuPrefsObject *mpo=(struct MenuPrefsObject *) &cbn[1];
  168.  ULONG sbits=mpo->mpo_StringBits;
  169.  UBYTE *ptr=(UBYTE *) &mpo[1];
  170.  char *name;
  171.  
  172.  /* Get name string */
  173.  name=(sbits & MOPO_NAME) ? GetConfigStr(&ptr) : DefaultNoName;
  174.  
  175.  /* Set string tags */
  176.  MenuPrefsTags[ 0].ti_Data=(ULONG) ((sbits & MOPO_EXEC) ?
  177.                                      GetConfigStr(&ptr) : NULL);
  178.  MenuPrefsTags[ 1].ti_Data=(ULONG) ((sbits & MOPO_SOUND) ?
  179.                                      GetConfigStr(&ptr) : NULL);
  180.  
  181.  /* Create object */
  182.  return(InternalCreateTMObject(PrivateTMHandle,name,TMOBJTYPE_MENU,
  183.                                MenuPrefsTags));
  184. }
  185.  
  186. static struct TagItem IconPrefsTags[]={
  187.                                        TMOP_Exec,     NULL,
  188.                                        TMOP_Image,    NULL,
  189.                                        TMOP_Sound,    NULL,
  190.  
  191.                                        TMOP_ShowName, FALSE,
  192.  
  193.                                        TMOP_LeftEdge, 0,
  194.                                        TMOP_TopEdge,  0,
  195.  
  196.                                        TAG_DONE
  197.                                       };
  198.  
  199. /* Interpret TMIC chunk */
  200. static BOOL ReadIconConfig(struct ConfigBufNode *cbn)
  201. {
  202.  struct IconPrefsObject *ipo=(struct IconPrefsObject *) &cbn[1];
  203.  ULONG sbits=ipo->ipo_StringBits;
  204.  UBYTE *ptr=(UBYTE *) &ipo[1];
  205.  char *name;
  206.  
  207.  /* Get name string */
  208.  name=(sbits & ICPO_NAME) ? GetConfigStr(&ptr) : DefaultNoName;
  209.  
  210.  /* Set string tags */
  211.  IconPrefsTags[ 0].ti_Data=(ULONG) ((sbits & ICPO_EXEC) ?
  212.                                      GetConfigStr(&ptr) : NULL);
  213.  IconPrefsTags[ 1].ti_Data=(ULONG) ((sbits & ICPO_IMAGE) ?
  214.                                      GetConfigStr(&ptr) : NULL);
  215.  IconPrefsTags[ 2].ti_Data=(ULONG) ((sbits & ICPO_SOUND) ?
  216.                                      GetConfigStr(&ptr) : NULL);
  217.  
  218.  /* Set boolean tags */
  219.  IconPrefsTags[ 3].ti_Data=(ipo->ipo_Flags & ICPOF_SHOWNAME) != 0;
  220.  
  221.  /* Set integer tags */
  222.  IconPrefsTags[ 4].ti_Data=ipo->ipo_XPos;
  223.  IconPrefsTags[ 5].ti_Data=ipo->ipo_YPos;
  224.  
  225.  /* Create object */
  226.  return(InternalCreateTMObject(PrivateTMHandle,name,TMOBJTYPE_ICON,
  227.                                IconPrefsTags));
  228. }
  229.  
  230. static struct TagItem DockPrefsTags[]={
  231.                                        TMOP_HotKey,    NULL,
  232.                                        TMOP_PubScreen, NULL,
  233.                                        TMOP_Title,     NULL,
  234.  
  235.                                        TMOP_Font,      NULL,
  236.  
  237.                                        TMOP_Activated, FALSE,
  238.                                        TMOP_Backdrop,  FALSE,
  239.                                        TMOP_Centered,  FALSE,
  240.                                        TMOP_FrontMost, FALSE,
  241.                                        TMOP_Menu,      FALSE,
  242.                                        TMOP_Pattern,   FALSE,
  243.                                        TMOP_PopUp,     FALSE,
  244.                                        TMOP_Sticky,    FALSE,
  245.                                        TMOP_Text,      FALSE,
  246.                                        TMOP_Vertical,  FALSE,
  247.  
  248.                                        TMOP_Columns,   0,
  249.                                        TMOP_LeftEdge,  0,
  250.                                        TMOP_TopEdge,   0,
  251.  
  252.                                        TAG_MORE,       NULL
  253.                                       };
  254.  
  255. struct ToolEntry {
  256.                   char *te_Exec;
  257.                   char *te_Image;
  258.                   char *te_Sound;
  259.                  };
  260. #define MAXTOOLS    1000
  261. #define TOOLBUFSIZE (MAXTOOLS*(sizeof(struct TagItem)+sizeof(struct ToolEntry)))
  262.  
  263. /* Interpret TMDO chunk */
  264. static BOOL ReadDockConfig(struct ConfigBufNode *cbn)
  265. {
  266.  char *toolbuf;
  267.  
  268.  /* Allocate memory for tools tags & strings */
  269.  if (toolbuf=AllocMem(TOOLBUFSIZE,MEMF_PUBLIC)) {
  270.   struct TagItem *tt=(struct TagItem *) toolbuf;
  271.   struct ToolEntry *te=(struct ToolEntry *)
  272.                         ((struct TagItem *) toolbuf + MAXTOOLS);
  273.   struct DockPrefsObject *dpo=(struct DockPrefsObject *) &cbn[1];
  274.   ULONG sbits=dpo->dpo_StringBits;
  275.   UBYTE *ptr=(UBYTE *) &dpo[1];
  276.   char *name;
  277.   BOOL rc;
  278.  
  279.   /* Get name string */
  280.   name=(sbits & DOPO_NAME) ? GetConfigStr(&ptr) : DefaultNoName;
  281.  
  282.   /* Set string tags */
  283.   DockPrefsTags[ 0].ti_Data=(ULONG) ((sbits & DOPO_HOTKEY) ?
  284.                                       GetConfigStr(&ptr) : NULL);
  285.   DockPrefsTags[ 1].ti_Data=(ULONG) ((sbits & DOPO_PSCREEN) ?
  286.                                       GetConfigStr(&ptr) : NULL);
  287.   DockPrefsTags[ 2].ti_Data=(ULONG) ((sbits & DOPO_TITLE) ?
  288.                                       GetConfigStr(&ptr) : NULL);
  289.  
  290.   /* Get font */
  291.   DockPrefsTags[ 3].ti_Data=
  292.    (ULONG) ((dpo->dpo_Font.ta_Name=(sbits & DOPO_FONTNAME) ?
  293.                                     GetConfigStr(&ptr) : NULL) ?
  294.             &dpo->dpo_Font : NULL);
  295.  
  296.   /* Set boolean tags */
  297.   DockPrefsTags[ 4].ti_Data=(dpo->dpo_Flags & DOPOF_ACTIVATED) != 0;
  298.   DockPrefsTags[ 5].ti_Data=(dpo->dpo_Flags & DOPOF_BACKDROP)  != 0;
  299.   DockPrefsTags[ 6].ti_Data=(dpo->dpo_Flags & DOPOF_CENTERED)  != 0;
  300.   DockPrefsTags[ 7].ti_Data=(dpo->dpo_Flags & DOPOF_FRONTMOST) != 0;
  301.   DockPrefsTags[ 8].ti_Data=(dpo->dpo_Flags & DOPOF_MENU)      != 0;
  302.   DockPrefsTags[ 9].ti_Data=(dpo->dpo_Flags & DOPOF_PATTERN)   != 0;
  303.   DockPrefsTags[10].ti_Data=(dpo->dpo_Flags & DOPOF_POPUP)     != 0;
  304.   DockPrefsTags[11].ti_Data=(dpo->dpo_Flags & DOPOF_STICKY)    != 0;
  305.   DockPrefsTags[12].ti_Data=(dpo->dpo_Flags & DOPOF_TEXT)      != 0;
  306.   DockPrefsTags[13].ti_Data=(dpo->dpo_Flags & DOPOF_VERTICAL)  != 0;
  307.  
  308.   /* Set integer tags */
  309.   DockPrefsTags[14].ti_Data=dpo->dpo_Columns;
  310.   DockPrefsTags[15].ti_Data=dpo->dpo_XPos;
  311.   DockPrefsTags[16].ti_Data=dpo->dpo_YPos;
  312.  
  313.   /* Read tool entries */
  314.   {
  315.    UBYTE tlflags;
  316.  
  317.    /* Get next tool entry */
  318.    while ((tlflags=*ptr++) & DOPOT_CONTINUE) {
  319.     /* Append tag */
  320.     tt->ti_Tag =TMOP_Tool;
  321.     tt->ti_Data=(ULONG) te;
  322.     tt++;
  323.  
  324.     /* Set tool entry strings */
  325.     te->te_Exec =(tlflags & DOPOT_EXEC)  ? GetConfigStr(&ptr) : NULL;
  326.     te->te_Image=(tlflags & DOPOT_IMAGE) ? GetConfigStr(&ptr) : NULL;
  327.     te->te_Sound=(tlflags & DOPOT_SOUND) ? GetConfigStr(&ptr) : NULL;
  328.     te++;
  329.    }
  330.   }
  331.  
  332.   /* Terminate tool tag array and chain both tag arrays */
  333.   tt->ti_Tag=TAG_DONE;
  334.   DockPrefsTags[17].ti_Data=(ULONG) toolbuf;
  335.  
  336.   /* Create object */
  337.   rc=InternalCreateTMObject(PrivateTMHandle,name,TMOBJTYPE_DOCK,DockPrefsTags);
  338.  
  339.   /* Free buffer */
  340.   FreeMem(toolbuf,TOOLBUFSIZE);
  341.   return(rc);
  342.  }
  343.  /* Call failed */
  344.  return(FALSE);
  345. }
  346.  
  347. static struct TagItem AccessPrefsTags[]={
  348.                                          TAG_MORE, NULL
  349.                                         };
  350.  
  351. #define MAXENTRIES 1000
  352. #define ENTRYBUFSIZE (MAXENTRIES*sizeof(struct TagItem))
  353.  
  354. /* Interpret TMAC chunk */
  355. static BOOL ReadAccessConfig(struct ConfigBufNode *cbn)
  356. {
  357.  char *entrybuf;
  358.  
  359.  /* Allocate memory for entry tags */
  360.  if (entrybuf=AllocMem(ENTRYBUFSIZE,MEMF_PUBLIC)) {
  361.   struct TagItem *et=(struct TagItem *) entrybuf;
  362.   struct AccessPrefsObject *apo=(struct AccessPrefsObject *) &cbn[1];
  363.   ULONG sbits=apo->apo_StringBits;
  364.   UBYTE *ptr=(UBYTE *) &apo[1];
  365.   char *name;
  366.   BOOL rc;
  367.  
  368.   /* Get name string */
  369.   name=(sbits & AOPO_NAME) ? GetConfigStr(&ptr) : DefaultNoName;
  370.  
  371.   /* Read access entries */
  372.   {
  373.    UBYTE aeflags;
  374.  
  375.    /* Get next tool entry */
  376.    while ((aeflags=*ptr++) & AOPOE_CONTINUE) {
  377.     /* Append tag */
  378.     et->ti_Tag =TMOP_Exec;
  379.  
  380.     /* Get Exec name */
  381.     et->ti_Data=(ULONG) ((aeflags & AOPOE_EXEC) ? GetConfigStr(&ptr) : NULL);
  382.  
  383.     /* Next tag */
  384.     et++;
  385.    }
  386.   }
  387.  
  388.   /* Terminate tool tag array and chain both tag arrays */
  389.   et->ti_Tag=TAG_DONE;
  390.   AccessPrefsTags[0].ti_Data=(ULONG) entrybuf;
  391.  
  392.   /* Create object */
  393.   rc=InternalCreateTMObject(PrivateTMHandle,name,TMOBJTYPE_ACCESS,
  394.                             AccessPrefsTags);
  395.  
  396.   /* Free buffer */
  397.   FreeMem(entrybuf,ENTRYBUFSIZE);
  398.   return(rc);
  399.  }
  400.  /* Call failed */
  401.  return(FALSE);
  402. }
  403.  
  404. static ReadConfigFuncPtr ReadConfigFunctions[TMOBJTYPES]={
  405.                                                           ReadExecConfig,
  406.                                                           ReadImageConfig,
  407.                                                           ReadSoundConfig,
  408.                                                           ReadMenuConfig,
  409.                                                           ReadIconConfig,
  410.                                                           ReadDockConfig,
  411.                                                           ReadAccessConfig
  412.                                                          };
  413.  
  414. /* Read config file */
  415. void ReadConfig(void)
  416. {
  417.  /* Open IFF parsing library */
  418.  if (IFFParseBase=OpenLibrary("iffparse.library",0)) {
  419.   struct IFFHandle *iff;
  420.  
  421.   DEBUG_PRINTF("IFF Library opened.\n");
  422.  
  423.   /* Alloc IFF handle */
  424.   if (iff=AllocIFF()) {
  425.  
  426.    DEBUG_PRINTF("IFF Handle (0x%08lx)\n",iff);
  427.  
  428.    /* Open IFF file */
  429.    if (iff->iff_Stream=Open(PrefsFileName,MODE_OLDFILE)) {
  430.     /* Init IFF handle */
  431.     InitIFFasDOS(iff);
  432.  
  433.     DEBUG_PRINTF("IFF Stream (0x%08lx)\n",iff->iff_Stream);
  434.  
  435.     /* Open IFF handle */
  436.     if (!OpenIFF(iff,IFFF_READ)) {
  437.  
  438.      DEBUG_PRINTF("IFF Opened\n");
  439.  
  440.      /* Start IFF parsing */
  441.      if (!ParseIFF(iff,IFFPARSE_STEP)) {
  442.       struct ContextNode *cn;
  443.  
  444.       DEBUG_PRINTF("First IFF scan step\n");
  445.  
  446.       /* Init config list */
  447.       NewList(&ConfigBufList);
  448.       clistinit=TRUE;
  449.  
  450.       /* Check IFF type and set IFF chunk types */
  451.       if ((cn=CurrentChunk(iff)) && (cn->cn_ID==ID_FORM) &&
  452.           (cn->cn_Type==ID_PREF) &&
  453.           !PropChunk(iff,ID_PREF,ID_PRHD) &&
  454.           !StopChunks(iff,stopchunks,TMOBJTYPES) &&
  455.           !StopOnExit(iff,ID_PREF,ID_FORM) &&
  456.           !ParseIFF(iff,IFFPARSE_SCAN)) {
  457.        /* First stop chunk encountered */
  458.        struct StoredProperty *sp;
  459.  
  460.        /* Get pointer to PRHD chunk */
  461.        if (sp=FindProp(iff,ID_PREF,ID_PRHD)) {
  462.         struct PrefHeader *ph=(struct PrefHeader *) sp->sp_Data;
  463.  
  464.         /* Check file version number */
  465.         if (ph->ph_Version==TMPREFSVERSION) {
  466.  
  467.          /* Parse IFF chunks */
  468.          do {
  469.           /* Get current chunk */
  470.           if (cn=CurrentChunk(iff)) {
  471.            LONG type;
  472.  
  473.            DEBUG_PRINTF("chunk ID: 0x%08lx",cn->cn_ID);
  474.            DEBUG_PRINTF(" size: 0x%08lx",cn->cn_Size);
  475.  
  476.            /* Read IFF chunk according to chunk ID */
  477.            switch(cn->cn_ID) {
  478.             case ID_TMEX: type=TMOBJTYPE_EXEC;
  479.                           break;
  480.             case ID_TMIM: type=TMOBJTYPE_IMAGE;
  481.                           break;
  482.             case ID_TMSO: type=TMOBJTYPE_SOUND;
  483.                           break;
  484.             case ID_TMMO: type=TMOBJTYPE_MENU;
  485.                           break;
  486.             case ID_TMIC: type=TMOBJTYPE_ICON;
  487.                           break;
  488.             case ID_TMDO: type=TMOBJTYPE_DOCK;
  489.                           break;
  490.             case ID_TMAC: type=TMOBJTYPE_ACCESS;
  491.                           break;
  492.             default:      type=-1;
  493.                           break;
  494.            }
  495.  
  496.            DEBUG_PRINTF(" type: %ld\n",type);
  497.  
  498.            /* valid type? */
  499.            if (type!=-1) {
  500.             ULONG sizechunk=cn->cn_Size;
  501.             ULONG sizebuf=sizechunk+sizeof(struct ConfigBufNode);
  502.             struct ConfigBufNode *cbn;
  503.  
  504.             /* Allocate memory for config buffer */
  505.             if (cbn=AllocMem(sizebuf,MEMF_PUBLIC)) {
  506.              /* Read chunk, interpret contents & create object */
  507.              if ((ReadChunkBytes(iff,cbn+1,sizechunk)==sizechunk) &&
  508.                  (*ReadConfigFunctions[type])(cbn)) {
  509.               /* Set size */
  510.               cbn->cbn_Size=sizebuf;
  511.  
  512.               /* Add node */
  513.               AddTail(&ConfigBufList,(struct Node *) cbn);
  514.               cbn=NULL;
  515.              }
  516.  
  517.              /* Error: free buffer */
  518.              if (cbn) FreeMem(cbn,sizebuf);
  519.             }
  520.  
  521.             DEBUG_PRINTF("cbn: 0x%08lx\n",cbn);
  522. /*            DEBUG_GETCHR(); */
  523.            }
  524.           }
  525.          /* Next parse step */
  526.          } while (!ParseIFF(iff,IFFPARSE_SCAN));
  527.         }
  528.        }
  529.       }
  530.      }
  531.      CloseIFF(iff);
  532.     }
  533.     Close(iff->iff_Stream);
  534.    }
  535.    FreeIFF(iff);
  536.   }
  537.   CloseLibrary(IFFParseBase);
  538.  }
  539. }
  540.  
  541. /* Free config buffers */
  542. void FreeConfig(void)
  543. {
  544.  struct ConfigBufNode *cbn;
  545.  
  546.  /* List valid? */
  547.  if (clistinit) {
  548.   /* Scan list, remove head entry */
  549.   while (cbn=(struct ConfigBufNode *) RemHead(&ConfigBufList))
  550.    /* Free entry */
  551.    FreeMem(cbn,cbn->cbn_Size);
  552.  
  553.   clistinit=FALSE;
  554.  }
  555. }
  556.